package com.WJY.controller;

import com.WJY.pojo.Dept;
import com.WJY.service.DeptService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import java.util.List;

@Controller
public class DeptController {

    //controller调service层

    @Autowired
    private DeptService deptService;

//    public void setDeptService(DeptService deptService) {
//        this.deptService = deptService;
//    }

    public void queryAllDeptList() {
        System.out.println(deptService.queryAllDept());
    }

    public void queryDeptOne(@Param("id") int id) {
        System.out.println(deptService.queryDeptById(id));
    }

    public void addDept(Dept dept) {
        System.out.println(deptService.addDept(dept) > 0 ? "新增成功" : "新增失败");
    }

    public void deleteDept(@Param("id") int id) {
        System.out.println(deptService.delDeptById(id) > 0 ? "删除成功" : "删除失败");
    }

    public void updateDeptOne(Dept dept) {
        System.out.println(deptService.updateDept(dept) > 0 ? "修改成功" : "修改失败");
    }
}
